<include file="Index/studentheader"/>
<style>
  .list-title {
    text-align: center;
    padding: 20px;
  }
  #examList {
    text-align: center;
  }
  th {
    text-align: center;
  }
</style>

<if condition="session('student')">
<else />
    <script type="text/javascript">
        window.location.href = '{:U("/Home/Student/login")}';
    </script>
</if>
<div class="list-title">
  <h1>考试信息</h1>
</div>
<div class="am-container">
  <div class="am-g am-u-sm-centered">
    <table class="am-table am-table-bordered" id="examList">
      <thead>
        <tr>
          <th>考试编号</th>
          <th>考试名称</th>
          <th>考试耗时</th>
          <th>实际耗时</th>
          <th>成绩</th>
        </tr>
      </thead>
    </table>
  </div>
</div>
<include file="Index/footer"/>

<script type="text/javascript">
  $(document)
    .ready(function($) {

      $
        .ajax({
          url: '{:U("/Home/Student/getExamList")}', type: 'POST', dataType: 'json', data: {
            student_id: '{:I("session.student")["student_id"]}'
          }
        })
        .done(function(response) {
          $('#examList').DataTable({
            "bProcessing": true, "bDestroy": true, "sPaginationType": "full_numbers", "oLanguage": {
              "sLengthMenu": "每页显示 _MENU_ 条记录",
              "sZeroRecords": "抱歉， 没有找到",
              "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
              "sInfoEmpty": "没有数据",
              "sInfoFiltered": "(从 _MAX_ 条数据中检索)",
              "sZeroRecords": "没有检索到数据",
              "sSearch": "搜索: &nbsp",
              "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "前一页",
                "sNext": "后一页",
                "sLast": "尾页"
              }
            },
            data: response,
            columns: [
              {
                data: 'exam_id'
              }, {
                data: 'name'
              }, {
                data: 'spend_time'
              }, {
                data: 'time_spent'
              }, {
                data: 'score'
              }
            ]
          });
        })
        .fail(function() {
          console.log("error");
        })
        .always(function() {
          console.log("complete");
        });
    });
</script>
